<script setup lang="ts">
import { ref } from 'vue';
import { useFoodStore } from '../stores/counter';

const foodStore = useFoodStore()


</script>

<template>
<div>
    <div class="compare">
        <div class="title">
            <b>已选择{{ foodStore.compareList.length }}</b>
            <RouterLink to="/type">去测评</RouterLink>
        </div>
        <div class="food-compare">
            <div class="food" 
            v-for="food in foodStore.compareList" 
            :key="food.name"
            @click="foodStore.addFood(food.name)"
            >
                <p>{{ food.name }}</p>
            </div>
        </div>
    </div>
</div>
</template>

<style lang="scss" scoped>
.compare{
    max-height: 300px;
    display: flex;
    flex-direction: column;
}
.title{
    display: flex;
    padding: 5px 10px;
    justify-content: space-between;
}
.food-compare{
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
}
.food{
    margin-right: 5px;
    margin-bottom: 5px;
    padding: 5px;
    border: 1px solid red;
}
</style>